﻿#include "Material.h"

#include "ShaderProgram.h"

bool FMaterial::Init()
{
	if (InitShaderWayType == EInitShaderWayType::SrcCode)
	{
		Shader = ShaderBuild().BuildWithSrcCode(GetVsSrcCode(), GetFsSrcCode());
	}
	else
	{
		const auto FsPath = this->GetFsSrcPath();
		const auto VsPath = this->GetVsSrcPath();

		assert(FsPath.extension() == ".fs" && "fs shader 的扩展名是不是写错了");
		assert(VsPath.extension() == ".vs" && "vs shader 的扩展名是不是写错了");

		Shader = ShaderBuild()
			.SetFragmentShaderFileName(FsPath)
			.SetVertexShaderFileName(VsPath)
			.Build();
	}
	return !!Shader;
}

void FMaterial::Use()
{
	Shader->Use();
}

static std::string EmptyStr;
const std::string& FMaterial::GetVsSrcCode() const
{
	return EmptyStr;
}

const std::string& FMaterial::GetFsSrcCode() const
{
	return EmptyStr;
}

std::filesystem::path FMaterial::GetVsSrcPath() const
{
	return "";
}

std::filesystem::path FMaterial::GetFsSrcPath() const
{
	return "";
}
